home *** CD-ROM | disk | FTP | other *** search
- #include "stdafx.h"
-
- cMovingStructure::cMovingStructure(int x, int y, cProperties *orig)
- : cStructure(x, y, orig)
- {
- current_waypoint = 0;
-
- waypoint_go_forward = TRUE;
-
- speed = 50;
- }
-
- cMovingStructure::~cMovingStructure()
- {
- }
-
- void cMovingStructure::load(cParse *list)
- {
- cStructure::load(list);
-
- speed = list->get_int("SPEED", 50);
- }
-
- void cMovingStructure::save()
- {
- cStructure::save();
-
- save_level_int("SPEED", speed);
- }
-
- int cMovingStructure::control()
- {
- // Call base class
-
- cStructure::control();
-
- // Move around
-
- fix d = waypoint_timer.delta() * speed;
-
- if (current_waypoint != 0)
- {
- if (square(d) >= (fix)d_square(x - current_waypoint->x, y - current_waypoint->y))
- {
- set_position(current_waypoint->x, current_waypoint->y);
-
- if (waypoint_go_forward)
- {
- if (current_waypoint->next == 0)
- {
- current_waypoint = (cSpot *)current_waypoint->prev;
-
- waypoint_go_forward = FALSE;
- }
- else
- {
- current_waypoint = (cSpot *)current_waypoint->next;
- }
- }
- else
- {
- if (current_waypoint->prev == 0)
- {
- current_waypoint = (cSpot *)current_waypoint->next;
-
- waypoint_go_forward = TRUE;
- }
- else
- {
- current_waypoint = (cSpot *)current_waypoint->prev;
- }
- }
- }
- else
- {
- add_angular_position(d, angle(current_waypoint->x - x, current_waypoint->y - y));
- }
- }
- else
- {
- current_waypoint = waypoints;
- }
-
- // Move some stuff around
-
- move_objects_on_boundaries(line_bounds, players);
- move_objects_on_boundaries(line_bounds, weapons);
- move_objects_on_boundaries(line_bounds, bonus);
-
- // Check end lifetime
-
- return !explode && !below_screen();
- }
-
- void cMovingStructure::create_editables(int select)
- {
- new cEditableMovingStructure(this, select);
-
- for (cSpot *w = waypoints; w != 0; w = (cSpot *)w->next)
- new cEditableMovingStructureWaypoint(this, w, select);
- }
-